package com.qianyu.project.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.qianyu.project.core.context.user.SysUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;


import java.io.Serializable;
import java.util.Collection;

/**
 * <p>
 * 
 * </p>
 *
 * @author gs
 * @since 2020-12-23
 */
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class SystemUser implements Serializable, UserDetails, SysUser {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    private String userName;

    private String userPwd;

    private String userRealname;

    private String userPhone;

    private String userEmail;

    private String userCreatedate;

    private String userPreDate;

    private Long userLoginNum;

    private Long hrEmpId;

    private String userStatus;

    private Integer companyId;

    @TableField(exist = false)
    private String roleName;

    @TableField(exist = false)
    private Integer roleId;

    @TableField(exist = false)
    private Collection<GrantedAuthority> grantedAuthorities;

    @TableField(exist = false)
    private String userRoles;

    @Override
    public Collection<GrantedAuthority> getAuthorities() {
        return this.grantedAuthorities;
    }

    @Override
    public String getPassword() {
        return this.userPwd;
    }

    @Override
    public String getUsername() {
        return this.userName;
    }

    @Override
    public String getUserRoles() {
        return this.userRoles;
    }

    @Override
    public String getRealName() {
        return this.userRealname;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
